electronic.alchemy :: poste.io upgrade
electronic.alchemy
where the past meets the future
smartos > poste.io upgrade

poste.io upgrade

Created by hww3. Last updated by hww3, 5 years ago. Version #4.

Note: Verified 3/10/2020

Updating an LX zone from an updated docker image is pretty simple; if you want to preserve data you'll need to do so before-hand, or have pre-configured your zone to store things in a delegated dataset, which will be preserved across reprovisions. The only real trick is that the reprovision will remove the init script we added to mount the delegated dataset and lofs-mount any directories into the filesystem. So, we'll make sure we put that back in, after the reprovision but before the zone is started back up.

This procedure also makes a backup of the zone just in case things go badly.

Note: though this is presented in the form of a shell script, DO NOT run it as such, but rather consider each line individually. Otherwise you'll likely trash your zone.

# import the new version of the image we want to run
imgadm import analogic/poste.io
# make note of the image uuid imported and set NEW_IMAGE to this value
UUID=91854c5c-a285-6522-9da8-e38a04116fd6
NEW_IMAGE=some_uuid
BACKUP_LOCATION=/zones/images/smtp-data.zfs
SNAPSHOT_NAME=begin

# stop the zone and make a copy of the zfs delegated setup script vmadm stop ${UUID} cp /zones/${UUID}/root/etc/cont-init.d/01-init-zfs.sh /tmp

# this is not strictly necessary, but sometimes it's nice to have a backup. echo "Backing up to $BACKUP_LOCATION..." zfs snap zones/${UUID}/data@${SNAPSHOT_NAME} zfs send -Recv zones/${UUID}/data@begin > $BACKUP_LOCATION

echo "Reprovisioning..." echo '{"image_uuid": "${NEW_IMAGE}"}' | vmadm reprovision ${UUID}

# restore the zfs delegated dataset bootstrap and truncated directory setup # scripts back into place. this is because they have to run the first time, every # time and thus can't be installed from /data/_override (which is a feature that # poste.io provides for making customizations to their image, and which is not # a standard feature across docker images). # # alternatively, we could override the docker:cmd field and do something there # or build a custom docker image. vmadm stop ${UUID} cp /tmp/0*.sh /zones/${UUID}/root/etc/cont-init.d/

#If, for some reason the container starts up immediately after provision, the zfs init script won't work as #the /data directory will be present and non-empty. If this happens, move it out of the way and restart. # then, zlogin and verify that the /data directory has the delegated dataset (with the local and _override directories) vmadm start ${UUID} # to restart with ipf running we have to reboot. vmadm reboot ${UUID}

# restoring the delegated dataset is not necessary when we use reprovision, but is # kept as an example of how to do it. zfs recv -F zones/${UUID}/data < ${BACKUP_LOCATION} zfs rollback zones/${UUID}/data@${SNAPSHOT_NAME} zfs destroy zones/${UUID}/data@${SNAPSHOT_NAME}

rm ${BACKUP_LOCATION}

Not categorized | RSS Feed | BackLinks

comments powered by Disqus